package com.dingding.common.core.util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

import org.apache.log4j.Logger;

/**
 * @Description:url编码工具
 * @author fengshuonan
 * @date 2016年9月5日 下午9:48:44
 * @version 叮叮搭车
 * @since 2.4
 */
public class UrlEncodeToolKit {
	
	private static Logger log = Logger.getLogger(UrlEncodeToolKit.class);
	
	public static String encode(String url){
		try {
			return URLEncoder.encode(url,"utf-8");
		} catch (UnsupportedEncodingException e) {
			log.error("编码出现错误，未识别的编码类型！UrlEncodeToolKit ：encode() ",e);
			return null;
		}
	}
	
	public static String decode(String url){
		try {
			return URLDecoder.decode(url,"utf-8");
		} catch (UnsupportedEncodingException e) {
			log.error("解码出现错误，未识别的编码类型！UrlEncodeToolKit ：decode() ",e);
			return null;
		}
	}

}
